﻿using B.S.Sterilizationcenter.Domain.zyy;
using B.S.Sterilizationcenter.ErrorCode;
using B.S.Sterilizationcenter.Read.API.Application.Command;
using B.S.Sterilizationcenter.Read.API.Application.Command.UsageManagements;
using MediatR;
using SqlSugar;

namespace B.S.Sterilizationcenter.Read.API.Application.Handler.UsageManagements
{
    public class FanUsagehandler : IRequestHandler<FanUsagecommand, ApiResult<List<UsageManagement>>>
    {
        private readonly ISqlSugarClient db;

        public FanUsagehandler(ISqlSugarClient db)
        {
            this.db = db;
        }

        public Task<ApiResult<List<UsageManagement>>> Handle(FanUsagecommand request, CancellationToken cancellationToken)
        {
            ApiResult<List<UsageManagement>> result = new ApiResult<List<UsageManagement>>();
            List<UsageManagement> list = db.Queryable<UsageManagement>().Where(o => o.UsageId == request.UsageId).ToList();
            result.Code = ApiEnums.查询成功;
            result.Msg = "查询成功";
            result.Data = list;
            return Task.FromResult(result);
        }
    }
}
